﻿#region Disclaimer/Info

/////////////////////////////////////////////////////////////////////////////////////////////////
//
//   File:		PageStructure.cs
//   Website:		http://dexterblogengine.com/
//   Authors:		http://dexterblogengine.com/About.ashx
//   Rev:		1
//   Created:		19/01/2011
//   Last edit:		19/01/2011
//   License:		GNU Library General Public License (LGPL)
//   File:            PageStructure.cs
//   For updated news and information please visit http://dexterblogengine.com/
//   Dexter is hosted to Codeplex at http://dexterblogengine.codeplex.com
//   For any question contact info@dexterblogengine.com
//
///////////////////////////////////////////////////////////////////////////////////////////////////

#endregion

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace Dexter.Domain.Model
{
	/// <summary>
	/// this entity acts like a view over the page and item objects, you need to keep the in sync
	/// this entoty should be used in a readonly way
	/// </summary>
	public class PageStructure : EntityBase
	{
		public PageStructure()
		{
			Pages = new List<PageStructure>();
		}

		public virtual string Title { get; set; }
		public virtual string Slug { get; set; }
		public virtual bool IsPublished { get; set; }
		public virtual int SortOrder { get; set; }
		public virtual PageStructure Parent { get; set; }
		public virtual IList<PageStructure> Pages { get; protected set; }
		public virtual ReadOnlyCollection<PageStructure> SortedPages { get {
			if(Pages != null)
				return new ReadOnlyCollection<PageStructure>(Pages.OrderBy(p => p.SortOrder).ToList());

			return new ReadOnlyCollection<PageStructure>(new List<PageStructure>());
		} }
	}
}
